package com.zhuss.outer.outer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.outer.outer.CreateOuterBo;
import com.zhuss.bean.bo.outer.outer.DeleteOuterBo;
import com.zhuss.bean.bo.outer.outer.UpdateOuterBo;
import com.zhuss.bean.bo.outer.outer.wechat.CollectOuterBo;
import com.zhuss.bean.bo.outer.outer.wechat.DelTopicOuterBo;
import com.zhuss.bean.bo.outer.outer.wechat.ForwardOuterBo;
import com.zhuss.bean.bo.outer.outer.wechat.ThumbOuterBo;
import com.zhuss.bean.bo.outer.outer.wechat.TopicOuterBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * outer操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("outerOperateService")
public class OuterOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("outerCreate")
	private Processor<Object, CreateOuterBo> outerCreate;
	
	@Autowired
	@Qualifier("outerUpdate")
	private Processor<Object, UpdateOuterBo> outerUpdate;
	
	@Autowired
	@Qualifier("outerDelete")
	private Processor<Object, DeleteOuterBo> outerDelete;
	
	@Autowired
	@Qualifier("outerThumb")
	private Processor<Object, ThumbOuterBo> outerThumb;
	
	@Autowired
	@Qualifier("outerCollect")
	private Processor<Object, CollectOuterBo> outerCollect;
	
	@Autowired
	@Qualifier("outerForward")
	private Processor<Object, ForwardOuterBo> outerForward;
	
	@Autowired
	@Qualifier("outerTopic")
	private Processor<Object, TopicOuterBo> outerTopic;
	
	@Autowired
	@Qualifier("outerDelThumb")
	private Processor<Object, ThumbOuterBo> outerDelThumb;
	
	@Autowired
	@Qualifier("outerDelCollect")
	private Processor<Object, CollectOuterBo> outerDelCollect;
	
	@Autowired
	@Qualifier("outerDelForward")
	private Processor<Object, ForwardOuterBo> outerDelForward;
	
	@Autowired
	@Qualifier("outerDelTopic")
	private Processor<Object, DelTopicOuterBo> outerDelTopic;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateOuterBo bo = (CreateOuterBo) param;
		
		outerCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateOuterBo bo = (UpdateOuterBo) param;
		
		outerUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteOuterBo bo = (DeleteOuterBo) param;
		
		outerDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void thumb(Object param) throws WpsException {
		
		ThumbOuterBo bo = (ThumbOuterBo) param;
		
		outerThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void collect(Object param) throws WpsException {
		
		CollectOuterBo bo = (CollectOuterBo) param;
		
		outerCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void forward(Object param) throws WpsException {
		
		ForwardOuterBo bo = (ForwardOuterBo) param;
		
		outerForward.process(bo);
		
		return null;
	}
	
	/**
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void topic(Object param) throws WpsException {
		
		TopicOuterBo bo = (TopicOuterBo) param;
		
		outerTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delThumb(Object param) throws WpsException {
		
		ThumbOuterBo bo = (ThumbOuterBo) param;
		
		outerDelThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delCollect(Object param) throws WpsException {
		
		CollectOuterBo bo = (CollectOuterBo) param;
		
		outerDelCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delForward(Object param) throws WpsException {
		
		ForwardOuterBo bo = (ForwardOuterBo) param;
		
		outerDelForward.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delTopic(Object param) throws WpsException {
		
		DelTopicOuterBo bo = (DelTopicOuterBo) param;
		
		outerDelTopic.process(bo);
		
		return null;
	}
	
}

